package basic.commons.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.security.SecureRandom;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;

import com.alibaba.dubbo.common.json.JSONObject;
//import net.sf.json.JSONObject;
import org.apache.log4j.Logger;


public class CommonUtil {

	private static Logger logger = Logger.getLogger(CommonUtil.class);

//
//		public static JSONObject httpsRequest(String requestUrl,String requestMethod, String outputStr) throws Exception {
//			JSONObject jsonObject = null;
//		URL url = new URL(requestUrl);
//		HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
//		TrustManager[] tm = { new LocalTrustManager() };
//		SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
//		sslContext.init(null, tm, new SecureRandom());
//		SSLSocketFactory ssf = sslContext.getSocketFactory();
//		conn.setSSLSocketFactory(ssf);
//		conn.setDoInput(true);
//		conn.setDoOutput(true);
//		conn.setRequestMethod(requestMethod);
//		if (null != outputStr) {
//			OutputStream outputStream = conn.getOutputStream();
//			outputStream.write(outputStr.getBytes("UTF-8"));
//			outputStream.close();
//		}
//
//		InputStream inputStream = conn.getInputStream();
//		InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
//		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//		StringBuffer buffer = new StringBuffer();
//		String str = null;
//		while ((str = bufferedReader.readLine()) != null) {
//			buffer.append(str);
//		}
//		bufferedReader.close();
//		inputStreamReader.close();
//		inputStream.close();
//		conn.disconnect();
//		jsonObject = JSONObject.parseObject(buffer.toString());
//		return jsonObject;
//	}
}
